#pragma once

#include <Utils.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/streambuf.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
#include <ipmi_fru_info_area.hpp>

#include <filesystem>
#include <fstream>
#include <iostream>
#include <regex>
#include <string>
class PSUInfo : public std::enable_shared_from_this<PSUInfo>
{
  public:
    PSUInfo(sdbusplus::asio::object_server& objectServer,
            std::shared_ptr<sdbusplus::asio::connection>& conn,
            const std::string& sensorName, const std::string& filePath);

    std::shared_ptr<sdbusplus::asio::dbus_interface> psuinfoInterface;
    std::shared_ptr<sdbusplus::asio::dbus_interface> versionIface;
    std::shared_ptr<sdbusplus::asio::dbus_interface> powersupplyIface;
    std::shared_ptr<sdbusplus::asio::dbus_interface> fwVersionIface;

    double_t formartPower(int power);
    int readPSUInfo(const std::string& propertyFileName, std::string& value);
    void updatePSUInfo(void);
    void snChanged(void);
    std::string getPSUModel(void);
    std::string getPSUManu(void);
    double getPSURatedPower(void);
    void psuInfoClear(void);
    std::vector<uint8_t> getFRUInfo();
    std::string psuSerialNum;
    std::string LastpsuSerialNum;
    ipmi::fru::FruInventoryData inventoryData;
    std::vector<uint8_t> fruRawData;

  private:
    sdbusplus::asio::object_server& objServer;
    std::shared_ptr<sdbusplus::asio::connection> conn;
    std::string sensorName;
    std::string filePath;
    std::string psuManu;
    std::string psuModel;
    double psuRatedPower;
};
